import { useStore } from "vuex";
import tipMixin from "@/baseFnMixin/playlist/playlistTip.js";
//  添加到播放列表,并且播放。
export default function () {
    const store = useStore();
    const tip = tipMixin();
    function AddPlay(data) {
        if (Object.prototype.toString.call(data) === "[object Object]") {
            store.commit("SongList/songlistAdd", data);
            store.dispatch("PlaySong/getSongUrl", data);
            store.dispatch("SongLyric/Lyric", data.id);
            tip("已开始播放");
        } else {
            store.commit("SongList/songlistAdd", data);
            store.dispatch("PlaySong/getSongUrl", data[0]);
            store.dispatch("SongLyric/Lyric", data[0].id);
            tip("已开始播放");
        }



    }
    return AddPlay

}